﻿<%@page import="java.util.HashMap"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<html>
<head>
<link rel="stylesheet" type="text/css" href="khutro/css/khutro.css">
<script src="js/gen_validatorv4.js" type="text/javascript"></script>
</head>
<body>

<s:form action="adminupdateuser.action" enctype="multipart/form-data" method="post" id="saveuserform">
	<div style="padding: 10px;">
		<div id="lable" style="width: 25%;float: left;">
			<div class="edituserfield">Email:</div>
			<div class="edituserfield">Last Visit:</div>
			<div class="edituserfield">Join Date:</div>
			<div class="edituserfield">Name:</div>
			<div class="edituserfield">User Group:</div>
			<div class="edituserfield">Banned:</div>
			<div class="edituserfield">Upload Avatar:</div>
			
		</div>
		<div id="inputf" style="width: 45%;float: left;">
			<div class="edituserfield"><span style="width:50%"><s:property value="lstusers[0][5]" /></span></div>
			<div class="edituserfield"><s:property value="lstusers[0][3]" /></div>
			<div class="edituserfield"><s:property value="lstusers[0][2]" /></div>
			<div class="edituserfield"><input type="text" id="displayName" name="displayName" value="<s:property value="lstusers[0][1]" />" maxlength="50"></div>
			<div class="edituserfield"><select name="reglevel" id="Roles">
											<option value="0">--all--</option>
												<s:iterator value="lstRoles">
													<s:if test="lstusers[0][6]==roleId">
														<option selected value="${roleId }">${roleName }</option>
													</s:if>
													<s:else>
														<option value="${roleId }">${roleName }</option>
													</s:else>
												</s:iterator>
										</select></div>
			<div class="edituserfield">
				<s:if test="lstusers[0][7]==1">
					<input type="checkbox" name="banned" value="1" checked>
				</s:if>
				<s:else>
				<input type="checkbox" name="banned" value="1">
				</s:else>
			</div>
			<div class="edituserfield"><input type="file" name="userImage" id="userImage" onchange="uploadchange();"></div>
		</div>
		<div id="inputf" style="width: 29%;float: left;">
		<!-- img avatar-->
			<img alt="avatar" src="<s:property value="lstusers[0][4]" />" width="150px" height="150px">
		</div>
	</div>
	<script type="text/javascript">
		function uploadchange() {
			var files = $('input[type="file"]')[0].files;
			
			var notok = 0;
			var i = 0;
			for (i = 0; i < files.length; i++) {
				if (files[i].size > 2097152) {
					notok = 1;
				}
				if (notok == 1) {
					$('#imageTopic').val("");
					alert("ảnh phải nhỏ hơn 2Mb");
				}
			}
			if (files.length > 10) {
				$('#imageTopic').val("");
				alert("Bạn chỉ được up tối đa 10 ảnh và ảnh phải nhỏ hơn 2Mb");

			}

		}
	</script>
<input type="hidden" name="usersId" value="<s:property value="lstusers[0][0]" />">
</s:form>
<script language="JavaScript" type="text/javascript"
		xml:space="preserve">
		//         
		var frmvalidator = new Validator("saveuserform");
		
		frmvalidator.addValidation("displayName", "req", "Tên hiển thị không được trống");
		frmvalidator.addValidation("userImage", "file_extn=jpg;jpeg;png",
		"+ File ảnh chỉ chấp nhận : jpg,jpeg,png");
		
	</script>
</body>
</html>